﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddCourse.aspx.cs" Inherits="NX5Web.admin.BaseData.MathConfig.AddCourse" %>

<div id="addCourseDialg">
    <el-dialog v-model="visible" title="添加课程" width="900" @close="handleClose">
        <div>
            <el-form label-width="auto" style="width:100%;">
                <el-form-item label="课程名称" required>
                    <el-input v-model="Title" clearable class="form-item-input"></el-input>
                </el-form-item>
                <el-form-item label="封面">
                    <el-input v-model="Conver" clearable class="form-item-input input-group">
                        <template #suffix>
                            <div style="height:30px;">
                                <el-upload action="/ApiFilter/UploadFiles.ashx" :limit="1" :show-file-list="false" :on-success="uploadImgSuc" accept="image/*">
                                    <template #trigger>
                                      <el-button type="primary" class="right-btn" icon="Upload"></el-button>
                                    </template>
                                </el-upload>
                            </div>
                        </template>
                    </el-input>
                </el-form-item>
                <el-form-item label="描述">
                    <el-input v-model="Describe" type="textarea" clearable class="form-item-input"></el-input>
                </el-form-item>
                <el-form-item label="排序">
                    <el-input-number v-model="Sort" :min="1" :controls="false" align="left" clearable></el-input-number>
                </el-form-item>
            </el-form>
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="handleClose">取 消</el-button>
                <el-button type="primary" @click="handleSaveData">保 存</el-button>
            </div>
        </template>
    </el-dialog>
</div>

<script>
    createApp({
        el: '#addCourseDialg',
        data() {
            return {
                BookId: '',
                visible: false,
                Title: '',
                Conver: '',
                Describe: '',
                Sort: 1
            }
        },
        methods: {
            uploadImgSuc(response, uploadFile) {
                this.Conver = response[0]["file"];
            },
            handleSaveData() {
                if (!this.Title) {
                    Notify.error("请输入课程名称！");
                    return;
                }
                ktlapi({
                    action: 'Cus_AddMathCourse',
                    data: {
                        BookId: this.BookId,
                        Title: this.Title,
                        Conver: SERVER_HOST + this.Conver,
                        Describe: this.Describe,
                        Sort: this.Sort
                    }
                }).then(resp => {
                    Notify.success("保存成功");
                    this.sendEmit({ action: 'refresh' })
                })
            },
            handleClose() {
                this.sendEmit({ action: 'close' })
            }
        },
        mounted() {
            this.visible = true;
            this.BookId = this.pageQuery;
        }
    })
</script>